home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / aurora2c.zip / COUNTWRD.AML < prev    next >
Text File  |  1995-04-07  |  1KB  |  40 lines

  1.  
  2. // ───────────────────────────────────────────────────────────────────
  3. // The Aurora Editor v2.0
  4. // Copyright 1993-1995 nuText Systems. All Rights Reserved Worldwide.
  5. //
  6. // Word counting macro
  7. //
  8. // Counts the number of words in the current file. The count is
  9. // limited to a marked block if it exists in the current file.
  10. // For this macro, words are defined to be contiguous sequences
  11. // of alphabetic characters (of any case) and the underline (_)
  12. // character.
  13. // ───────────────────────────────────────────────────────────────────
  14.  
  15.   // compile time macros and function definitions
  16.   include  bootpath "define.aml"
  17.  
  18.   // test for edit windows
  19.   if not wintype? "edit" then
  20.     msgbox "Edit windows only!"
  21.     return
  22.   end
  23.  
  24.   // test if a marked block exists in the current file
  25.   block_count = mark? and getmarkbuf == getcurrbuf
  26.  
  27.   // display message
  28.   say "Counting words" + (if? block_count " in block") + "..."
  29.  
  30.   // count words using regular expression searching
  31.   count = find "[a-zA-Z_]#"  "axg" + (if? block_count 'b')
  32.  
  33.   // clear the title bar
  34.   display
  35.  
  36.   // display the word count
  37.   shortbox  (if? count (thousands count) "No") + " words found" +
  38.             (if? block_count " in the block")
  39.  
  40.